package com.java.thread.demo.chapter1.lsAlive;

/**
 * Created by yiyongyao on 2017/12/18.
 */
public class CountOperate extends Thread {

    /***
     * 构造函数的启动是由main线程启动,this代表的是countOperate的新线程
     */
    public CountOperate() {
        System.out.println("CountOperate === > begin");
        System.out.println("Thread.currentThread.getName()="+Thread.currentThread().getName());
        System.out.println("Thread.currentThread.isAlive()="+Thread.currentThread().isAlive());
        System.out.println("this.getName()"+this.getName());
        System.out.println("this.isAlive()"+this.isAlive());
        System.out.println("CountOperate === > end");
    }

    /**
     * 在thread.start()执行后 run才执行,新线程才产生 this 才有生命
     */
    @Override
    public void run() {
        System.out.println("run === > begin");
        System.out.println("Thread.currentThread.getName()="+Thread.currentThread().getName());
        System.out.println("Thread.currentThread.isAlive()="+Thread.currentThread().isAlive());
        System.out.println("this.getName()"+this.getName());
        System.out.println("this.isAlive()"+this.isAlive());
        System.out.println("run === > end");
    }
}
